#include<iostream>
using namespace std;
const int N = 100000;
int a[N], l[N], r[N], idx;
void init()
{
    r[0] = 1;
    l[1] = 0;
    idx = 2;
}
void left_insert(int x)
{
    a[idx] = x;
    l[idx] = 0;
    r[idx] = r[0];
    l[r[0]] = idx;
    r[0] = idx++;
}
void right_insert(int x)
{
    a[idx] = x;
    r[idx] = 1;
    l[idx] = l[1];
    r[l[1]] = idx;
    l[1] = idx++;
}
void insertleft(int k, int x)
{
    a[idx] = x;
    r[idx] = k;
    l[idx] = l[k];
    r[l[k]] = idx;
    l[k] = idx++;
}
void insertright(int k, int x)
{
    a[idx] = x;
    l[idx] = k;
    r[idx] = r[k];
    l[r[k]] = idx;
    r[k] = idx++;
}
void remove(int k)
{
    r[l[k]] = r[k];
    l[r[k]] = l[k];
}
int main()
{
    int m = 0, k = 0, x = 0;
    cin >> m;
    string c;
    init();
    while (m--)
    {
        cin >> c;
        if (c == "L")
        {
            cin >> x;
            left_insert(x);
        }
        else if (c == "R")
        {
            cin >> x;
            right_insert(x);
        }
        else if (c == "D")
        {
            cin >> k;
            remove(k + 1);
        }
        else if (c == "IL")
        {
            cin >> k >> x;
            insertleft(k + 1, x);
        }
        else if (c == "IR")
        {
            cin >> k >> x;
            insertright(k + 1, x);
        }
    }
    for (int i = r[0]; i != 1; i = r[i]) cout << a[i] << ' ';
    cout << endl;

    return 0;
}

